package com.collabscm.sample.demo.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import com.collabscm.pf.persistence.NamedDynamicQueries;
import com.collabscm.pf.persistence.NamedDynamicQuery;
import com.collabscm.pf.persistence.WhereJoinType;

/**
 * TestParty的实体类，此类主要是为了演示如何使用JPA和Bean Validation.
 * 
 * @author Zeng Raoxing
 */
@Entity
@Table(name = "test_t_party")
@NamedQueries({
	@NamedQuery(name="TestParty.getMax", query="select MAX(t.partyId) from TestParty t"),
	@NamedQuery(name="TestParty.getIdAndNameList", query="select t." + TestParty.partyIdAttrName + ", t.partyName from TestParty t")
})
@NamedNativeQueries({
	@NamedNativeQuery(name="TestParty.getNativeIdAndNameList", query="select party_id, party_name from test_t_party where party_name = ?1", resultClass=TestParty.class)
})
@NamedDynamicQueries (
	@NamedDynamicQuery(name="TestParty", query="select t from TestParty t where @t.partyName=:partyName and @t.creator=:creator", joinType=WhereJoinType.AND)
)
public class TestParty implements java.io.Serializable {
	private static final long serialVersionUID = 1L;
	//Columns
	public static final String partyIdColumn = "party_id";
	public static final String partyIdAttrName = "partyId";
	@NotNull
	private Integer partyId;
	// Fields
	
	private String partyName;
	private Integer hight;
	private Integer wight;
	private Integer creator;
	private Date createdTime;
	private Integer updator;
	private Date updatedTime;
	private String enableFlag;


	/** default constructor */
	public TestParty() {
	}

	/** minimal constructor */
	public TestParty(Integer partyId, String partyName, Integer creator, Date createdTime, Integer updator,
			Date updatedTime, String enableFlag) {
		this.partyId = partyId;
		this.partyName = partyName;
		this.creator = creator;
		this.createdTime = createdTime;
		this.updator = updator;
		this.updatedTime = updatedTime;
		this.enableFlag = enableFlag;
	}

	/** full constructor */
	public TestParty(Integer partyId, String partyName, Integer hight, Integer wight, Integer creator,
			Date createdTime, Integer updator, Date updatedTime, String enableFlag) {
		this.partyId = partyId;
		this.partyName = partyName;
		this.hight = hight;
		this.wight = wight;
		this.creator = creator;
		this.createdTime = createdTime;
		this.updator = updator;
		this.updatedTime = updatedTime;
		this.enableFlag = enableFlag;
	}

	// Property accessors

	@Id
	@Column(name = partyIdColumn, nullable = false)
	public Integer getPartyId() {
		return this.partyId;
	}

	public void setPartyId(Integer partyId) {
		this.partyId = partyId;
	}

	@Column(name = "party_name", nullable = false, length = 60)
	public String getPartyName() {
		return this.partyName;
	}

	public void setPartyName(String partyName) {
		this.partyName = partyName;
	}

	@Column(name = "hight")
	public Integer getHight() {
		return this.hight;
	}

	public void setHight(Integer hight) {
		this.hight = hight;
	}

	@Column(name = "wight")
	public Integer getWight() {
		return this.wight;
	}

	public void setWight(Integer wight) {
		this.wight = wight;
	}

	@Column(name = "creator", nullable = false)
	public Integer getCreator() {
		return this.creator;
	}

	public void setCreator(Integer creator) {
		this.creator = creator;
	}

	@Column(name = "created_time", nullable = false, length = 19)
	public Date getCreatedTime() {
		return this.createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	@Column(name = "updator", nullable = false)
	public Integer getUpdator() {
		return this.updator;
	}

	public void setUpdator(Integer updator) {
		this.updator = updator;
	}

	@Column(name = "updated_time", nullable = false, length = 19)
	public Date getUpdatedTime() {
		return this.updatedTime;
	}

	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}

	@Column(name = "enable_flag", nullable = false, length = 1)
	public String getEnableFlag() {
		return this.enableFlag;
	}

	public void setEnableFlag(String enableFlag) {
		this.enableFlag = enableFlag;
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof TestParty))
			return false;
		TestParty castOther = (TestParty) other;

		return ((this.getPartyId() == castOther.getPartyId()) || (this.getPartyId() != null
				&& castOther.getPartyId() != null && this.getPartyId().equals(castOther.getPartyId())))
				&& ((this.getPartyName() == castOther.getPartyName()) || (this.getPartyName() != null
						&& castOther.getPartyName() != null && this.getPartyName().equals(castOther.getPartyName())))
				&& ((this.getHight() == castOther.getHight()) || (this.getHight() != null
						&& castOther.getHight() != null && this.getHight().equals(castOther.getHight())))
				&& ((this.getWight() == castOther.getWight()) || (this.getWight() != null
						&& castOther.getWight() != null && this.getWight().equals(castOther.getWight())))
				&& ((this.getCreator() == castOther.getCreator()) || (this.getCreator() != null
						&& castOther.getCreator() != null && this.getCreator().equals(castOther.getCreator())))
				&& ((this.getCreatedTime() == castOther.getCreatedTime()) || (this.getCreatedTime() != null
						&& castOther.getCreatedTime() != null && this.getCreatedTime().equals(
						castOther.getCreatedTime())))
				&& ((this.getUpdator() == castOther.getUpdator()) || (this.getUpdator() != null
						&& castOther.getUpdator() != null && this.getUpdator().equals(castOther.getUpdator())))
				&& ((this.getUpdatedTime() == castOther.getUpdatedTime()) || (this.getUpdatedTime() != null
						&& castOther.getUpdatedTime() != null && this.getUpdatedTime().equals(
						castOther.getUpdatedTime())))
				&& ((this.getEnableFlag() == castOther.getEnableFlag()) || (this.getEnableFlag() != null
						&& castOther.getEnableFlag() != null && this.getEnableFlag().equals(castOther.getEnableFlag())));
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result + (getPartyId() == null ? 0 : this.getPartyId().hashCode());
		result = 37 * result + (getPartyName() == null ? 0 : this.getPartyName().hashCode());
		result = 37 * result + (getHight() == null ? 0 : this.getHight().hashCode());
		result = 37 * result + (getWight() == null ? 0 : this.getWight().hashCode());
		result = 37 * result + (getCreator() == null ? 0 : this.getCreator().hashCode());
		result = 37 * result + (getCreatedTime() == null ? 0 : this.getCreatedTime().hashCode());
		result = 37 * result + (getUpdator() == null ? 0 : this.getUpdator().hashCode());
		result = 37 * result + (getUpdatedTime() == null ? 0 : this.getUpdatedTime().hashCode());
		result = 37 * result + (getEnableFlag() == null ? 0 : this.getEnableFlag().hashCode());
		return result;
	}

}